package com.gpframework.module.controller.wages;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.gpframework.common.core.controller.BaseController;
import com.gpframework.common.core.domain.AjaxResult;
import com.gpframework.common.core.page.TableDataInfo;
import com.gpframework.common.utils.DateUtils;
import com.gpframework.module.wages.domain.vo.*;
import com.gpframework.module.wages.service.IGzPersonnelFoundationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@Validated
@Api(tags = "工资统计接口")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@SuppressWarnings({"rawtypes","unchecked"})
@RequestMapping("/form" )
public class GpFormsStatistics extends BaseController {


    private final IGzPersonnelFoundationService iGzPersonnelFoundationService;


    @ApiOperation("工资汇总")
    @GetMapping("/SalarySummary")
    public TableDataInfo<SalarySummaryVo> salarySummary(@JsonFormat(pattern = "yyyy-MM") Date month, String deptName) {
        startPage();
        if (month==null){
            return getError("请输入月份进行查询");
        }

        List<SalarySummaryVo> list = iGzPersonnelFoundationService.salarySummary(DateUtils.parseDateToStr("yyMMdd",month),deptName);
        return getDataTable(list);
    }

    @ApiOperation("人事版本")
    @GetMapping("/personnelVersion")
    public TableDataInfo<GzPersonnelVersionVo> personnelVersion(@JsonFormat(pattern = "yyyy-MM") Date month, String deptName, String name) {
        startPage();
        if (month==null){
            return getError("请输入月份进行查询");
        }
        List<GzPersonnelVersionVo> list = iGzPersonnelFoundationService.personnelVersion(DateUtils.parseDateToStr("yyMMdd",month),deptName,name);
        return getDataTable(list);
    }


    @ApiOperation("档口及办公室工资工资汇总")
    @GetMapping("/officeSalarySummary")
    public AjaxResult<GzOfficeSalaryVo> officeSalarySummary(@JsonFormat(pattern = "yyyy-MM") Date month , String deptName) {
        List<GzOfficeSalaryVo> list=null;
        if(month!=null){
            list = iGzPersonnelFoundationService.gzOfficeSalarySummary(DateUtils.parseDateToStr("yyMMdd",month),deptName);
        }
        return AjaxResult.success(list);
    }

    @ApiOperation("中转工资汇总")
    @GetMapping("/transfeSummary")
    public AjaxResult<GzTransferVo> transfeSummary(@JsonFormat(pattern = "yyyy-MM") Date month , String deptName) {
        List<GzTransferVo> list=null;
        if (month!=null){
            list = iGzPersonnelFoundationService.transfeSummary(DateUtils.parseDateToStr("yyMMdd",month),deptName);
        }
        return AjaxResult.success(list);
    }

    @ApiOperation("仓库人员工资汇总")
    @GetMapping("/warehouseSummary")
    public AjaxResult<GzWarehousePersonnelVo> gzOfficeSalarySummary(@JsonFormat(pattern = "yyyy-MM") Date month , String deptName) {
        List<GzWarehousePersonnelVo> list=null;
        if (month!=null){
            list = iGzPersonnelFoundationService.warehouseSummary(DateUtils.parseDateToStr("yyMMdd",month),deptName);
        }
        return AjaxResult.success(list);
    }





}
